@main
struct StatusBarApp: App {
    @NSApplicationDelegateAdaptor(AppDelegate.self) var delegate

    var body: some Scene {
        WindowGroup {}
    }
}

class AppDelegate: NSObject, NSApplicationDelegate {

    private var statusBarItem: NSStatusItem?

    func applicationDidFinishLaunching(_ notification: Notification) {
        setupStatusBar()
    }

    // 设置状态栏图标及其行为
    private func setupStatusBar(){
        self.statusBarItem = NSStatusBar.system.statusItem(withLength: CGFloat(NSStatusItem.variableLength))
        
        if let button = self.statusBarItem?.button {
            button.image = NSImage(systemSymbolName: "bell", accessibilityDescription: nil)
            button.action = #selector(togglePopover(sender:))
        }
    }

    @objc private func togglePopover(sender: AnyObject?) {
        // 这里可以添加更多逻辑以展示或隐藏 Popover 视窗
    }
}